package com.starview.star.compiler.canonical;

import com.starview.platform.data.type.Location;
import com.starview.platform.data.type.TypeUtils;
import com.starview.star.compiler.standard.StandardNames;
import com.starview.star.compiler.util.PrettyPrintDisplay;

/**
 * A Shriek is a reference to the value of a read/write variable
 * 
 * @author fgm
 * 
 */
@SuppressWarnings("serial")
public class Shriek extends BaseExpression
{
  private final IContentExpression reference;

  public Shriek(Location loc, IContentExpression reference)
  {
    super(loc, TypeUtils.referencedType(reference.getType()));
    this.reference = reference;
  }

  public IContentExpression getReference()
  {
    return reference;
  }

  @Override
  public void prettyPrint(PrettyPrintDisplay disp)
  {
    disp.appendWord(StandardNames.SHRIEK);
    reference.prettyPrint(disp);
  }

  @Override
  public void accept(CanonicalVisitor visitor)
  {
    visitor.visitReference(this);
  }

  @Override
  public <A, E, P, C, D, T> E transform(TransformExpression<A, E, P, C, D, T> transform, T context)
  {
    return transform.transformReference(this, context);
  }
}
